#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>

/*
 * 比较参数timep1和timep2时间是否相同，并返回之间相差秒数
 */

void main()
{
  time_t timep1, timep2;

  timep1 = time(NULL);
  sleep(2);
  timep2 = time(NULL);
  printf("the difference is %f seconds\n", difftime(timep1, timep2));

  timep1 = time(NULL);
  usleep(2);
  timep2 = time(NULL);

  printf("the difference is %f seconds\n", difftime(timep1, timep2));
}
